package business;

import java.util.List;

import models.Conversation;
import models.forms.ConversationForm;
import dao.ConversationDao;
import dao.impl.ConversationDaoImpl;

public class ConversationBusiness {
	private ConversationDao conversationDao;
	
	public ConversationBusiness(){
		conversationDao = new ConversationDaoImpl();
	}
	
	public void insert(ConversationForm conversationForm){
		Conversation conversation = new Conversation();
		conversation.setDatetime(conversationForm.getDatetime());
		conversation.setOwnerId(new org.bson.types.ObjectId(conversationForm.getOwnerId()));
		conversation.setOwnerName(conversationForm.getOwnerName());
		conversation.setDestinateId(new org.bson.types.ObjectId(conversationForm.getDestinateId()));
		conversation.setDestinateType(conversationForm.getDestinateType());
		conversation.setContent(conversationForm.getContent());
		conversation.setContentType(conversationForm.getContentType());
		conversation.setMessageType(conversationForm.getMessageType());
		conversation.setExchangeName(conversationForm.getExchangeName());
		conversation.setRoutingKey(conversationForm.getRoutingKey());
		
		conversationDao.insert(conversation);
	}
	
	public List<Conversation> selectByDestId(String destinationId){
		return conversationDao.selectByDestinateId(destinationId);
	}
	
	public List<Conversation> selectInByRoutingKey(List<String> routingKeys){
		return conversationDao.selectInByRoutingKey(routingKeys);
	}
}
